//
//  QCVisitorViewController.swift
//  SwiftDemoWithSina
//
//  Created by qu on 2017/1/17.
//  Copyright © 2017年 Apple. All rights reserved.
//

import UIKit

class QCVisitorViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    let isLogin: Bool = QCOAuthViewModel.shared.isLogin
    var visitorView: QCVisitorView?
    
    lazy var tableView: UITableView = UITableView()
    override func loadView() {
        if isLogin {
            view = tableView
        } else {
            setupVisitorView()
        }
    }
    private func setupVisitorView() {
      
        setupNav()
        visitorView = QCVisitorView()
        visitorView?.closure = {[weak self] in
            
           self?.loginBtnClick()
        }
       view = visitorView
    }
    
    private func setupNav(){
        
navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: nil, title: "登录", target: self
            , action: #selector(loginBtnClick))
navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: nil, title: "注册", target: self, action: #selector(loginBtnClick))
    }
    
    @objc private func loginBtnClick() {
        
        let oauthVC = QCOAuthViewController()
        self.present(QCNavViewController(rootViewController:oauthVC), animated: true, completion: nil)
        
    }
}
